// i.d(t, { a: () => Snapshot })
import categoryEnum from "../enum/category.enum"
import viewmodeEnum from "../enum/viewmode.enum"
import ObservableObject from "../observer/observable.object"
import ExpiringResource from "../utils/ExpiringResource"
interface metaData {
  cameraMode: number
  cameraPosition: THREE.Vector3
  cameraQuaternion: THREE.Quaternion
  scanId: string
  orthoZoom: number
  ssZoom: number
  floorId: string
  floorVisibility: number[]
}
export default class Snapshot extends ObservableObject {
  category: string
  sid: string
  thumbnailUrl: ExpiringResource
  imageUrl: ExpiringResource
  name: string
  is360: boolean
  height: number
  width: number
  created: Date
  modified: Date
  visionLabel: string
  visionName: string
  imageBlob: Blob
  metadata: metaData
  state: string
  constructor() {
    super()
    this.category = categoryEnum.USER
  }
  clone() {
    return new Snapshot().copy(this)
  }
  copy(e: Partial<Snapshot>) {
    this.sid = e.sid
    this.thumbnailUrl = e.thumbnailUrl
    this.imageUrl = e.imageUrl
    this.name = e.name || ""
    this.is360 = e.is360
    this.category = e.category
    this.height = e.height
    this.width = e.width
    this.created = e.created
    this.modified = e.modified
    this.visionLabel = e.visionLabel
    this.visionName = e.visionName
    this.imageBlob = e.imageBlob
    this.metadata = {
      cameraMode: e.metadata.cameraMode,
      cameraPosition: e.metadata.cameraPosition.clone(),
      cameraQuaternion: e.metadata.cameraQuaternion.clone(),
      scanId: e.metadata.scanId,
      orthoZoom: e.metadata.orthoZoom,
      ssZoom: e.metadata.ssZoom,
      floorId: e.metadata.floorId,
      floorVisibility: e.metadata.floorVisibility
    }
    return this
  }
  isInsidePano() {
    return this.metadata.cameraMode === viewmodeEnum.Panorama && "" !== this.metadata.scanId
  }
  refresh(e: Snapshot) {
    this.thumbnailUrl.refreshFrom(e.thumbnailUrl)
    this.imageUrl.refreshFrom(e.imageUrl)
  }
}
